﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using MapEditor;
using Microsoft.Xna.Framework.Input;

namespace PFAGame
{
    class Cursor
    {
        Texture2D texture;
        Vector2I position = new Vector2I();
        MouseState mouseState;

        public Vector2I Position
        {
            get { return position; }
            set { position = value; Mouse.SetPosition(position.x, position.y);  }
        }

        public MouseState MouseState
        {
            get { return mouseState; }
        }

        public void Init()
        {
            singleton = this;
        }

        public void Update(GameTime gameTime)
        {
            if (texture == null)
                texture = ScreenManager.Singleton.Game.Content.Load<Texture2D>("cursor");
            mouseState = Mouse.GetState();
            
            position.x = mouseState.X;
            position.y = mouseState.Y;
        }

        public void Draw(GameTime gameTime)
        {
            Rectangle displayRectangle = new Rectangle(position.x, position.y, texture.Width, texture.Height);
            ScreenManager.Singleton.SpriteBatch.Begin();
            ScreenManager.Singleton.SpriteBatch.Draw(texture, displayRectangle, Color.White);
            ScreenManager.Singleton.SpriteBatch.End();
        }

        public static Cursor Singleton
        {
            get { return singleton; }
        }
        private static Cursor singleton;
    }
}
